package com.zhijian.medical.controller;

import com.zhijian.medical.annotation.Response;
import com.zhijian.medical.entity.po.TTcAlarmTemplate;
import com.zhijian.medical.entity.vo.request.TTcAlarmTemplateSearchVo;
import com.zhijian.medical.entity.vo.response.TTcAlarmTemplateVo;
import com.zhijian.medical.service.TTcAlarmTemplateService;
import com.zhijian.medical.util.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 告警模板表 控制层
 *
 * @Author Auto Generator
 * @DateTime 2021-09-01 23:13:20
 * @version: 1.0.1
 */
@Slf4j
@Controller
@Api(tags = "告警模板表")
public class TcAlarmTemplateController {

    @Autowired
    private TTcAlarmTemplateService service;

    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/tc/alarm/template")
    @ApiOperation("新增")
    public boolean insert(@RequestBody TTcAlarmTemplate param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.insert(param) != null;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/tc/alarm/template/{id}")
    @ApiOperation("删除")
    public void delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
    }

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/tc/alarm/template/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody TTcAlarmTemplate param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.update(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/tc/alarm/template/{id}")
    @ApiOperation("根据id查询")
    public TTcAlarmTemplateVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param tTcAlarmTemplateSearchVo
     * @return
     */
    @Response
    @PostMapping("/tc/alarm/template/page")
    @ApiOperation("分页查询")
    public Page<TTcAlarmTemplateVo> page(@RequestBody TTcAlarmTemplateSearchVo tTcAlarmTemplateSearchVo) {
        return service.selectPage(tTcAlarmTemplateSearchVo);
    }

    /**
     * 列表查询，不分页
     *
     * @return
     */
    @Response
    @GetMapping("/tc/alarm/template/list")
    @ApiOperation("列表查询，不分页")
    public List<TTcAlarmTemplateVo> selectList() {
        return service.selectList(TTcAlarmTemplateSearchVo.builder().build());
    }

}